import { Divider, Select } from "antd";
import {
  settingsType,
  settingType,
  settingsFromType,
} from "../../../api/types";
export default function Remind({
  str,
  options,
  defaultValue,
  onchange,
}: {
  str: string;
  options: settingsType;
  defaultValue: number;
  onchange: (id: number, type: string, value: number) => void;
}) {
  const change = (_: string, value: settingType | settingsType) => {
    console.log(value);

    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
    // @ts-expect-error
    onchange(value.id, settingsFromType[str], value.value);
  };
  const defaultname: settingType | undefined = options.find((item) => {
    if (item.id === defaultValue) {
      return item;
    }
  });
  return (
    <>
      <div className="remind" style={{ display: "flex" }}>
        <div className="remind-str">{str}</div>
        <div>提醒时间：</div>
        <Select
          className="select"
          defaultValue={defaultname?.name}
          onChange={change}
          options={options}
        ></Select>
      </div>
      <Divider></Divider>
    </>
  );
}
